home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / nw3bug.c < prev    next >
C/C++ Source or Header  |  1991-08-12  |  5KB  |  165 lines

  1. /*
  2.  
  3. 08-12-91
  4.  
  5. This code demonstrates what I believe is a bug in Netware 3.11. The bug keeps
  6. NetWare from correctly reporting file access violations on file to which I have
  7. only read access. The bug occurs when the file is opened. I've included a copy
  8. of a session that demonstrates the bug.
  9.  
  10.    1. F:\USR\MTSJMC>bcc nw3bug.c
  11.       Borland C++  Version 2.0 Copyright (c) 1991 Borland International
  12.       nw3bug.c:
  13.       Turbo Link  Version 4.0 Copyright (c) 1991 Borland International
  14.  
  15.               Available memory 286592
  16.  
  17.    2. F:\USR\MTSJMC>dir >testfile
  18.  
  19.    3. F:\USR\MTSJMC>nw3bug testfile
  20.       Opened testfile for read-only (r) access.
  21.       Opened testfile for read-write (r+) access.
  22.       Opened testfile for write (w) access.
  23.       Created (w+) testfile.
  24.  
  25.    4. F:\USR\MTSJMC>dir >testfile
  26.  
  27.    5. F:\USR\MTSJMC>flag testfile ro
  28.            TESTFILE                 [ Ro - A - - -- - - -- -- -- DI RI ]
  29.  
  30.    6. F:\USR\MTSJMC>nw3bug testfile
  31.       Opened testfile for read-only (r) access.
  32.       Opened testfile for read-write (r+) access.
  33.       Opened testfile for write (w) access.
  34.       Created (w+) testfile.
  35.  
  36.    7. F:\USR\MTSJMC>del testfile
  37.       Access denied
  38.  
  39.    8. F:\USR\MTSJMC>c:
  40.  
  41.    9. C:\>dir >testfile
  42.  
  43.   10. C:\>attrib testfile +r
  44.  
  45.   11. C:\>f:nw3bug testfile
  46.       Opened testfile for read-only (r) access.
  47.       Cannot open testfile for read-write (r+) access.
  48.       Cannot open testfile for write (w) access.
  49.       Cannot create (w+) testfile.
  50.  
  51. Step 1 compiles NW3BUG.C (this file) to NW3BUG.EXE using Borland C++ version
  52. 2.0. This is VERY generic code, so no ANSI C compiler should have any trouble
  53. with it.
  54.  
  55. Step 2 generates a test file called TESTFILE in my file space on our file
  56. server.
  57.  
  58. Step 3 shows a run of NW3BUG on a normal test file. The results it shows are
  59. correct.
  60.  
  61. Steps 4, 5, and 6 recreate the test file, make it a read-only file, and run
  62. NW3BUG on the new test file. The results are the same as those of step 3. This
  63. is NOT correct.
  64.  
  65. Step 7 demonstrates that TESTFILE realy is a read-only file and is protected
  66. against deletion. If you do a TYPE on TESTFILE at this point, you will see that
  67. its contents were not wiped out as they were reported to be in the fourth
  68. message of step 6.
  69.  
  70. Steps 8, 9, and 10 change the current drive to by local hard disk, create a new
  71. test file there, and make it a read-only file.
  72.  
  73. Step 11 shows how NW3BUG behaves with a read-only file on a DOS volume. These
  74. results are different from those shown in step 6 and are correct.
  75.  
  76. My conclusion from this experiment is that NetWare does not report file access
  77. violations the way that DOS does. The session above shows only one of the tests
  78. I ran. Other experiments involved a read-write file that had been placed into a
  79. directory to which I had no write access, tests on DOS without any network
  80. drivers loaded at all, and using different network drivers (NET4 rather than my
  81. usual XMSNET4). All the results pointed to the same bug in NetWare. I would be
  82. interested to hear of your own experiments involving NW3BUG or a similar
  83. program of your own creation.
  84.  
  85. To be reasonable, it is concievable that I have something set incorrectly in my
  86. SHELL.CFG file, so here's a copy of it:
  87.  
  88.     SHORT MACHINE TYPE = IBM
  89.     LONG MACHINE TYPE = IBM
  90.     LOCAL PRINTERS = 0
  91.     SEARCH MODE = 1
  92.     SHARE = ON
  93.     TASK MODE = 0
  94.     SPX ABORT TIMEOUT = 2000
  95.     show dots = on
  96.     preferred server = ccmts
  97.  
  98. System configuration:
  99.  
  100.     IBM PS/2 model 55sx
  101.     IBM DOS 4.01
  102.     IPX version 3.02 with IBM Token Ring driver version 2.61
  103.     XMSNET3 version 3.01
  104.  
  105.     File server:
  106.         IBM PS/2 model 80
  107.         NetWare 3.11
  108.  
  109. I realize that running this experiment takes time and that the people who
  110. are capable of running this experiment are very likely to have plenty work
  111. to do as it is. So let me thank you in advance for your time and talent.
  112.  
  113. Jeff Clough
  114. System Communications Analyst (==Programmer)
  115. Georgia State University Computer Center
  116.  
  117.   CIS: 76264,2073
  118. Voice: 404-651-2639
  119.   FAX: 404-651-4579
  120.  
  121. */
  122.  
  123. #include <stdio.h>
  124.  
  125. int main(int argc,char **argv) {
  126.   FILE *f;
  127.   if (argc<2) {
  128.     puts("Pass a filename of the command line.");
  129.     return 1;
  130.   }
  131.   /* Open the file for read-only access.
  132.   */
  133.   if ((f=fopen(*++argv,"r"))==0)
  134.     printf("Cannot open %s for read-only (r) access.\n",*argv);
  135.   else {
  136.     printf("Opened %s for read-only (r) access.\n",*argv);
  137.     fclose(f);
  138.   }
  139.   /* Open the file for read-write access.
  140.   */
  141.   if ((f=fopen(*argv,"r+"))==0)
  142.     printf("Cannot open %s for read-write (r+) access.\n",*argv);
  143.   else {
  144.     printf("Opened %s for read-write (r+) access.\n",*argv);
  145.     fclose(f);
  146.   }
  147.   /* Open the file for write access.
  148.   */
  149.   if ((f=fopen(*argv,"w"))==0)
  150.     printf("Cannot open %s for write (w) access.\n",*argv);
  151.   else {
  152.     printf("Opened %s for write (w) access.\n",*argv);
  153.     fclose(f);
  154.   }
  155.   /* Create (or recreate) the file.
  156.   */
  157.   if ((f=fopen(*argv,"w+"))==0)
  158.     printf("Cannot create (w+) %s.\n",*argv);
  159.   else {
  160.     printf("Created (w+) %s.\n",*argv);
  161.     fclose(f);
  162.   }
  163.   return 0;
  164. }
  165.